package strutil

func SubstringByRuneIndexFrom(str string, from int) string {
	runes := []rune(str)
	if from < 0 || from >= len(runes) {
		return ""
	}
	return string(runes[from:])
}

func SubstringByRuneIndexTo(str string, to int) string {
	runes := []rune(str)
	if to < 0 || to > len(runes) {
		return ""
	}
	return string(runes[:to])
}

func SubstringByRuneIndexFromTo(str string, from int, to int) string {
	runes := []rune(str)
	if from < 0 || from >= len(runes) {
		return ""
	}
	if to < 0 || to > len(runes) {
		return ""
	}
	if from >= to {
		return ""
	}
	return string(runes[from:to])
}
